package algorithm.view.maze;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;

/**
 * @author bingo
 * @Description 迷宫数据
 * @Date 2018/5/22
 */

public class MazeData {
    /**入口的X,Y坐标*/
    private  int entranceX,entranceY;

    /**出口的X,Y坐标*/
    private int exitX,exitY;
    /**迷宫数据*/
    private char[][] data;
    /**行*/
    private int l;
    /**列*/
    private int m;

    public  boolean[][] visited;


    public boolean[][] path;

/**采用非递归算法的结果*/
    public boolean[][] result;

    public static   char  WALL='#';

    public static   char  RODE =' ';

    /**返回多少行*/
    public int getL() {
        return l;
    }

    public void setL(int l) {
        this.l = l;
    }

    /**返回多少列*/
    public int getM() {
        return m;
    }

    public void setM(int m) {
        this.m = m;
    }

    /**返回迷宫数据*/
    public char[][] getData() {
        return data;
    }
    /**返回入口x坐标*/
    public int getEntranceX() {
        return entranceX;
    }

    public void setEntranceX(int entranceX) {
        this.entranceX = entranceX;
    }
    /**返回入口y坐标*/
    public int getEntranceY() {
        return entranceY;
    }

    public void setEntranceY(int entranceY) {
        this.entranceY = entranceY;
    }

    public int getExitX() {
        return exitX;
    }

    public void setExitX(int exitX) {
        this.exitX = exitX;
    }

    public int getExitY() {
        return exitY;
    }

    public void setExitY(int exitY) {
        this.exitY = exitY;
    }

    public MazeData(String fileName) {
        File file = new File(fileName);
        Scanner scanner = null;
        try {
            FileInputStream fileInputStream = new FileInputStream(file);
            scanner = new Scanner(fileInputStream,"utf-8");
            String[] datas = scanner.nextLine().split(" ");
            this.l = Integer.valueOf(datas[0]);
            this.m = Integer.valueOf(datas[1]);
            this.data = new char[l][m];
            this.visited = new boolean[l][m];
            this.path = new boolean[l][m];
            this.result = new boolean[l][m];
            for(int i=0;i<l;i++){
                String line = scanner.nextLine();
                if(line.length()!=m){
                    throw new IllegalArgumentException();
                }
                for(int j=0;j<m;j++){
                    data[i][j]=line.charAt(j);
                    visited[i][j]=false;
                    path[i][j] = false;
                    result[i][j]=false;
                }

              }
               exitX=1;
               exitY=0;
               entranceX = l-2;
               entranceY = m-1;
               entranceY = m-1;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

    }

    public boolean inArea(int x,int y){

        return  x >= 0 && x < l && y >= 0 && y < m;

    }
    public static void main(String[] args) {
        MazeData data  = new MazeData("demo/maze.txt");
        System.out.println(data.getL());
        System.out.println(data.getM());

    }
}
